//
// Decompiled by Jadx - 411ms
//
package p;

import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import androidx.appcompat.app.t;
import com.google.gson.Gson;
import dq.b;
import fi.w;
import fn.y;
import gc.aa;
import gj.r;
import java.util.List;
import java.util.Objects;
import me.plusne.NativeTools;
import me.plusne.common.Http.Home;
import me.plusne.common.Http.Hook;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.JsonIssueCheck;
import me.plusne.common.Json.JsonMsg;
import me.plusne.common.Json.Login.JsonHookData;
import me.plusne.common.Json.Login.JsonTempUserDecrypt;

public final class a {

    @SuppressLint({"StaticFieldLeak"})
    public static w a;

    public static void b(String str, String str2, String str3, r rVar) {
        if (y.by.getUserInfo() == null) {
            return;
        }
        t.c().j(((Hook) b.b(Hook.class)).addYunData(str, str2, str3).subscribeWith(rVar));
    }

    public static void c(boolean z) {
        List list;
        JsonHookData jsonHookData = (JsonHookData) new Gson().fromJson(fn.b.g("jsonHookData", ""), JsonHookData.class);
        JsonHookStatic jsonHookStatic = y.by;
        if (jsonHookStatic.getUserInfo() == null || jsonHookData == null) {
            return;
        }
        JsonTempUserDecrypt jsonTempUserDecrypt = (JsonTempUserDecrypt) new Gson().fromJson(NativeTools.p(jsonHookData.getUser()), JsonTempUserDecrypt.class);
        if (jsonHookStatic.getVersionCode() == jsonHookData.getCode() && (list = (List) new Gson().fromJson(NativeTools.p(jsonHookData.getData()), new a().getType())) != null) {
            jsonHookStatic.setHookData(list);
        }
        if (jsonTempUserDecrypt != null) {
            jsonHookStatic.setTimeDecrypt(jsonTempUserDecrypt.getTime());
            jsonHookStatic.setTimeDifference((System.currentTimeMillis() / 1000) - jsonTempUserDecrypt.getTime());
            jsonHookStatic.getUserInfo().setLevel(jsonTempUserDecrypt.getLevel());
            jsonHookStatic.getUserInfo().setExp(jsonTempUserDecrypt.getExp());
            jsonHookStatic.getUserInfo().setPay(jsonTempUserDecrypt.getPayType());
            jsonHookStatic.getUserInfo().setDeviceEncode(jsonTempUserDecrypt.getDeviceEncode());
            if (!z) {
                jsonHookStatic.setMd5(jsonTempUserDecrypt.getMd5());
                return;
            }
            synchronized (a.class) {
                w wVar = a;
                if (wVar != null) {
                    wVar.az();
                }
                if (TextUtils.isEmpty(jsonHookStatic.getMd5()) || !Objects.equals(jsonHookStatic.getMd5(), jsonTempUserDecrypt.getMd5()) || y.cd(0, "update_version") != jsonHookStatic.getVersionCode()) {
                    new Handler(Looper.getMainLooper()).postDelayed(new aa(8, "适配数据有变化,重启\"" + jsonHookStatic.getAppName() + "\" 生效\n利用拉起PlusNE主程序来重新启动", jsonTempUserDecrypt), 1500L);
                }
            }
        }
    }

    public static void d(b<JsonMsg> bVar) {
        if (y.by.getUserInfo() == null) {
            return;
        }
        t.c().j(((Hook) b.b(Hook.class)).queryUserInfo().subscribeWith(bVar));
    }

    public static void e(String str, String str2, b<JsonIssueCheck> bVar) {
        t.c().j(((Home) b.b(Home.class)).userCheck(str, str2).subscribeWith(bVar));
    }
}
